﻿using Uber.Core.Repository;
using Uber.Core.Service;

namespace Uber.Service
{
    public class BannedIps : IBannedIps
    {
        private readonly IBannedIpRepo repo;

        public BannedIps(IBannedIpRepo repo)
        {
            this.repo = repo;
        }

        public bool IsBanned(string ip)
        {
            return repo.Count(ip).Equals(1);
        }

        public bool UnBan(string ip)
        {
            return repo.Delete(ip).Equals(1);
        }

        public bool Ban(string ip)
        {
            return repo.Insert(ip).Equals(1);
        }
    }
}